/**
 * 作者：
 * 创建时间：2012-10-23 上午8:34:21
 */
package dragon.model.fieldTemplate.dataprovider;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import dragon.core.exception.ExceptionHandler;
import dragon.core.util.StringUtils;
import dragon.model.bizObject.BizObject;
import dragon.model.bizObject.BizObjectContainer;
import dragon.model.bizObject.BizProcess;
import dragon.model.fieldTemplate.IFieldTemplateDataProvider;

/**
 * 实现功能：业务操作数据提供者
 */
public class BizProcessDataProvider implements IFieldTemplateDataProvider {

	@Override
	public Collection<?> getData(Map<String, String> parameterMap) throws ExceptionHandler {
		String bizCode = parameterMap.get("CODE");
		if (!StringUtils.isEmpty(bizCode)) {
			BizObject bizObject = BizObjectContainer.get(bizCode);
			List<BizProcess> processes = bizObject.getProcesses();
			List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(processes.size());
			Map<String, Object> map = null;
			for (BizProcess process : processes) {
				map = new HashMap<String, Object>();
				map.put("VALUE", process.getCode());
				map.put("TEXT", process.getName());
				list.add(map);
			}
			map = null;
			processes = null;
			bizObject = null;
			return (Collection<?>) list;
		}
		return null;
	}

}
